Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development


Adding a new table to the Repository

If your application requires data that cannot easily be represented in the Repository database tables, you can add an additional table or tables to store it. Whether you actually add these tables to the Repository database itself (ICFDB) or to your application database is up to you. In either case, you can join the new tables to other Repository tables to provide a connection between standard Repository data and your extensions.

In this case, you need a new table to store the field edit definitions for the manager to use. This is an extension to the Repository definition of entities (tables) and their fields. When you import entity definitions into the Repository as the first step in defining a Progress Dynamics application for your database, the framework creates an Entity Mnemonic record for each table, and an entity display field record for each field in the table, with some of its display characteristics, such as its label and format. The Object Generator uses this data to create the default SDOs, browsers, and viewers that make up the starter set of objects in the application.

Figure 7–2 shows these two standard Repository tables.

Figure 7–2: Standard Repository tables

To support the Field Edit Manager, you must add an additional table to store field edit information for each field. The table is called gsc_entity_field_edit. You can create it in the OpenEdge Data Dictionary. The table contains the fields described in Table 7–1.

Table 7–1: The gsc_entity_field_edit table
Field
Description
entity_field_edit_obj 
This DECIMAL field is the object ID for the record itself.
entity_display_field_obj  
This DECIMAL field is the object ID of the associated gsc_entity_display_field record to join to.
edit_type  
This CHARACTER field stores the code for the special edit type, such as Required or Case.
edit_value 
This CHARACTER field stores the value for the edit type, such as Yes for Required, or Upper or Lower for Case.

You must have a unique primary index on the entity_field_edit_obj field, and a second index on this field plus the edit_type field.

When creating the new table, provide the appropriate format for the object ID fields, with nine decimals to assure that the site ID for the database is properly encoded, as shown in Figure 7–3.

Figure 7–3: Field Properties window

Use a CREATE trigger procedure to define code that assigns the next available object ID to each new record. The procedure must include the standard framework code that defines the getNextObj function and invoke it to assign the ID. The Table Triggers window is shown in Figure 7–4.

Figure 7–4: Table Triggers dialog box

How does the field edit data gets into the new table? Presumably, you create a tool where developers define special edits, but that is beyond the scope of this discussion. You can populate the table using a procedure to define some test values, such as the following example, which marks the CustNum, Name, City, State, and Country fields in the Sports2000 database Customer table as required fields, and the State field as requiring uppercase. For example:

FOR EACH gsc_entity_display_field WHERE entity_mnemonic = 'customer': 
    IF LOOKUP(display_field_name, 'custnum,name,city,state,country') NE 0 THEN 
    DO: 
        CREATE gsc_entity_field_edit. 
        ASSIGN gsc_entity_field_edit.entity_display_field_obj =  
                 gsc_entity_display_field.entity_display_field_obj 
               gsc_entity_field_edit.edit_type = "Required" 
               gsc_entity_field_edit.edit_value = "YES". 
    END. 
    IF display_field_name = 'State' THEN 
    DO: 
        CREATE gsc_entity_field_edit. 
        ASSIGN gsc_entity_field_edit.entity_display_field_obj =  
                 gsc_entity_display_field.entity_display_field_obj 
               gsc_entity_field_edit.edit_type = "Case" 
               gsc_entity_field_edit.edit_value = "Upper". 
    END.END. 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095